/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-03-27 11:21:29
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-03-27 18:15:18
 * @FilePath: \project\node-project\server\config\db.config.js
 * @Description: 
 */
const mongoose = require('mongoose');

mongoose.connect("mongodb://127.0.0.1:27017/company-system");

mongoose.connection.on("open", () => {
    // 在这里可以执行链接成功的操作
    console.log('mongodb 数据库连接成功!')
})

// 监听连接错误事件
mongoose.connection.on("error",(err) => {
    console.error("MongoDB 连接错误:", err)
})